package org.sixtythousand.joker.http;

import org.sixtythousand.joker.handler.AbstractHandlerWrapper;
import org.sixtythousand.joker.handler.Handler;
import org.sixtythousand.joker.Request;
import org.sixtythousand.joker.Response;

/**
 * @author zhoulk
 * @date 2023/10/12 16:14
 * @desc
 */
public class HttpHandlerWrapper extends AbstractHandlerWrapper {

    protected Request request;
    protected AbstractHttpRequest abstractHttpRequest;
    protected String path;
    protected UrlMatcher urlMatcher = new UrlMatcher();

    public HttpHandlerWrapper(String path, Handler handler) {
     }

    @Override
    public void handle(Request request, Response response) {
        Handler tHandler = handler;
        if (tHandler != null) {
            tHandler.handle(request, response);
        }
    }

    @Override
    public boolean match(Request request) {
        AbstractHttpRequest abstractHttpRequest = (AbstractHttpRequest) request;
        return urlMatcher.match(path, abstractHttpRequest);
    }


}
